<template>
    <div class="home">
        <button @click="goNews">新闻</button>
    </div>
</template>

<script>
    // @ is an alias to /src
    import HelloWorld from "@/components/HelloWorld.vue"

    export default {
        name: "Home",
        components: {
            HelloWorld
        },
        data() {
            return {}
        },

        methods: {
            goNews() {
                //动态路由
                this.$router.push({
                    // path: `/news/1?search=xx`
                    path: `/news/1`,
                    query: {
                        search: "xxx"
                    }
                })
                // this.$router.push({
                //     name: `News`,
                //     params: {newsId: 2}
                // })
            }
        }
    }
</script>
